package com.xu.cloud.auth.enums;

import lombok.Getter;
import org.springframework.lang.Nullable;

/**
 * 登录名枚举
 *
 * @author xuguan
 * @since 2025/2/27
 */
@Getter
public enum LoginNameEnum {
    USER_NAME("userName", "用户名"),
    MOBILE_NO("mobileNo", "手机号"),
    EMAIL("email", "邮箱"),
    ;

    private final String loginType;
    private final String loginDesc;

    LoginNameEnum(String loginType, String loginDesc) {
        this.loginType = loginType;
        this.loginDesc = loginDesc;
    }

    @Nullable
    public static LoginNameEnum getByLoginType(String loginType) {
        for (LoginNameEnum value : values()) {
            if (value.getLoginType().equals(loginType)) {
                return value;
            }
        }
        return null;
    }
}
